//
// Created by LiuYou on 2020/8/2.
//

#ifndef CLASSWITHCOMPOSITION_PC_H
#define CLASSWITHCOMPOSITION_PC_H


#include <ostream>
#include "Cpu.h"
#include "HardDisk.h"
#include "ClassInfo.h"

namespace ly {
    class Pc : public ClassInfo {
    private:
        Cpu cpu;
        HardDisk* hardDisk;
    public:
        explicit Pc(const Cpu& cpu, HardDisk* hardDisk = nullptr) : cpu(cpu), hardDisk(hardDisk) {}

        ~Pc() override = default;

        HardDisk* getHardDisk() const {
            return hardDisk;
        }

        void setHardDisk(HardDisk* hardDisk) {
            Pc::hardDisk = hardDisk;
        }

        const Cpu& getCpu() const {
            return cpu;
        }

        void setCpu(const Cpu& cpu) {
            Pc::cpu = cpu;
        }

        friend std::ostream& operator<<(std::ostream& os, const Pc& pc) {
            os << "cpu: " << pc.cpu << " hardDisk: " << *pc.hardDisk;
            return os;
        }

        std::string toString() override {
            return (std::string) "Pc{" +
                   "cpu=" + cpu.toString() +
                   ", hardDisk=" + hardDisk->toString() +
                   '}';
        }
    };
}


#endif //CLASSWITHCOMPOSITION_PC_H
